#pragma once
#include "network_base.h"
#include "timer.h"

enum TCP_STATUS {
	HEADER_STATUS = 0,
	BODY_STATUS = 1
};

//TCP网络监听类
class TcpNetwork : public NetworkBase
{
public:
	TcpNetwork(struct event_base* event_base);
protected:
	virtual NetworkSessionBase* NewSession(int fd) override;
};

//TCP网络会话类
class TcpNetworkSession : public NetworkSessionBase
{
public:
	TcpNetworkSession(struct event_base* event_base)
		: NetworkSessionBase(event_base)
		, _status(HEADER_STATUS)
		, _proto_length(0)
	{
	}
	virtual void Send(const char* data, size_t length) override;
	virtual void Send(const std::string& str) override;
protected:
	virtual int HandleMessage() override;
	void xorFunc(string& str);
	virtual int BeforeDestroy() override;
protected:
	TCP_STATUS _status;
	uint32_t _proto_length;
};